<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
use Storage;

class ExportReportController extends Controller
{
    /* 导出Excel 检测报告*/
    public function export(Request $request) {
        $app_name = config('constant.app_name');
        // dd($app_name);
        if($request->sample == 1){
            $className = "App\\Http\\Controllers\\Admin\\ExportReportSample\\{$app_name}Controller";
            if (!class_exists($className)) {
                $className = "App\\Http\\Controllers\\Admin\\ExportReportSample\\PublicController";
            }
        }else{
            $className = "App\\Http\\Controllers\\Admin\\ExportReport\\ExportReport{$app_name}Controller";
            if (!class_exists($className)) {
                $className = "App\\Http\\Controllers\\Admin\\ExportReport\\ExportReportPublicController";
            }
        }
        // dd($className);
        $exportReport = new $className();
        return $exportReport->export($request);
    }

    /* 导出批次原始记录*/
    public function origin(Request $request) {
        $app_name = config('constant.app_name');
        // $app_name = "HuiBangJianCe";
        $className = "App\\Http\\Controllers\\Admin\\ExportOrigin\\{$app_name}Controller";
        if (!class_exists($className)) {
            $className = "App\\Http\\Controllers\\Admin\\ExportOrigin\\PublicController";
        }
        $exportReport = new $className();
        return $exportReport->export($request);
    }

}
